package ru.usu.gv.styles;

import java.awt.Color;

/**
 @author Sergey Pupyrev 
 25.03.2007
 */

public class StyleFacade implements StyleConstants
{
	private static Style defaultStyle = new Style("styles/default.style.xml");
	private static Style currentStyle = new Style("styles/default.style.xml");

	//default
	public static double getDefaultDoubleAttribute(String path)
	{
		return defaultStyle.getDoubleAttribute(path);
	}

	public static int getDefaultIntegerAttribute(String path)
	{
		return defaultStyle.getIntegerAttribute(path);
	}

	public static boolean getDefaultBooleanAttribute(String path)
	{
		return defaultStyle.getBooleanAttribute(path);
	}

	public static String getDefaultStringAttribute(String path)
	{
		return defaultStyle.getStringAttribute(path);
	}

	//current
	public static Style getCurrentStyle()
	{
		return currentStyle;
	}

	private static double getDoubleAttribute(Style style, String path)
	{
		return style.getDoubleAttribute(path);
	}

	private static void setDoubleAttribute(Style style, String path, double value)
	{
		style.setDoubleAttribute(path, value);
	}

	private static int getIntegerAttribute(Style style, String path)
	{
		return style.getIntegerAttribute(path);
	}

	private static void setIntegerAttribute(Style style, String path, int value)
	{
		style.setIntegerAttribute(path, value);
	}

	private static boolean getBooleanAttribute(Style style, String path)
	{
		return style.getBooleanAttribute(path);
	}

	private static void setBooleanAttribute(Style style, String path, boolean value)
	{
		style.setBooleanAttribute(path, value);
	}

	public static String getStringAttribute(Style style, String path)
	{
		return style.getStringAttribute(path);
	}

	public static void setStringAttribute(Style style, String path, String value)
	{
		style.setStringAttribute(path, value);
	}

	//Specific properties
	//1. Vertex
	public static String getVertexType(Style style)
	{
		return getStringAttribute(style, VERTEX_TYPE_ATTRIBUTE);
	}

	public static String getVertexType()
	{
		return getVertexType(currentStyle);
	}

	public static double getVertexSize(Style style)
	{
		return getDoubleAttribute(style, VERTEX_SIZE_ATTRIBUTE);
	}

	public static double getVertexSize()
	{
		return getVertexSize(currentStyle);
	}

	public static boolean isShowVertexLabel(Style style)
	{
		return getBooleanAttribute(style, SHOW_VERTEX_LABEL_ATTRIBUTE);
	}

	public static boolean isShowVertexLabel()
	{
		return isShowVertexLabel(currentStyle);
	}

	public static Color getVertexColor(Style style)
	{
		String stringColor = getStringAttribute(style, VERTEX_COLOR_ATTRIBUTE);
		return StyleUtilities.decodeColor(stringColor);
	}

	public static Color getVertexColor()
	{
		return getVertexColor(currentStyle);
	}

	public static int getMaxCountVertex(Style style)
	{
		return getIntegerAttribute(style, VERTEX_MAXCOUNT_ATTRIBUTE);
	}

	public static int getMaxCountVertex()
	{
		return getMaxCountVertex(currentStyle);
	}

	//2. Edge
	public static double getEdgeLength(Style style)
	{
		return getDoubleAttribute(style, EDGE_LENGTH_ATTRIBUTE);
	}

	public static double getEdgeLength()
	{
		return getEdgeLength(currentStyle);
	}

	public static double getEdgeRadius(Style style)
	{
		return getDoubleAttribute(style, EDGE_RADIUS_ATTRIBUTE);
	}

	public static double getEdgeRadius()
	{
		return getEdgeRadius(currentStyle);
	}

	public static String getEdgeType(Style style)
	{
		return getStringAttribute(style, EDGE_TYPE_ATTRIBUTE);
	}

	public static String getEdgeType()
	{
		return getEdgeType(currentStyle);
	}

	public static Color getEdgeColor(Style style)
	{
		String stringColor = getStringAttribute(style, EDGE_COLOR_ATTRIBUTE);
		return StyleUtilities.decodeColor(stringColor);
	}

	public static Color getEdgeColor()
	{
		return getEdgeColor(currentStyle);
	}

	public static boolean isShowEdges(Style style)
	{
		return getBooleanAttribute(style, EDGE_SHOW_ATTRIBUTE);
	}

	public static boolean isShowEdges()
	{
		return isShowEdges(currentStyle);
	}

	public static boolean isShowControlPoints()
	{
		return isShowControlPoints(currentStyle);
	}

	public static boolean isShowControlPoints(Style style)
	{
		return getBooleanAttribute(style, EDGE_SHOW_CP_ATTRIBUTE);
	}

	public static int getMaxCountEdges(Style style)
	{
		return getIntegerAttribute(style, EDGE_MAXCOUNT_ATTRIBUTE);
	}

	public static int getMaxCountEdges()
	{
		return getMaxCountEdges(currentStyle);
	}

	//3. Common
	public static boolean isDirectedGraph(Style style)
	{
		return getBooleanAttribute(style, DIRECTED_GRAPH_ATTRIBUTE);
	}

	public static void setDirectedGraph(boolean directed)
	{
		setBooleanAttribute(currentStyle, DIRECTED_GRAPH_ATTRIBUTE, directed);
	}

	public static boolean isDirectedGraph()
	{
		return isDirectedGraph(currentStyle);
	}

	public static String getLocale(Style style)
	{
		return getStringAttribute(style, LOCALE_ATTRIBUTE);
	}

	public static String getLocale()
	{
		return getLocale(currentStyle);
	}

	public static boolean is3D(Style style)
	{
		return getBooleanAttribute(style, DIMENSIONS_ATTRIBUTE);
	}

	public static void set3D(boolean _3D)
	{
		setBooleanAttribute(currentStyle, DIMENSIONS_ATTRIBUTE, _3D);
	}

	public static boolean is3D()
	{
		return is3D(currentStyle);
	}
	
}
